home *** CD-ROM | disk | FTP | other *** search
- /* sentence.c - count sentences */
- #include "stdio.h"
-
- int ns ;
-
- main()
- {
- int c ;
- ns = 0 ;
- /* get each charcter and check it */
- c = getchar() ;
- while( c != EOF )
- { check_end(c) ;
- c = getchar() ;
- }
-
- printf(" %d sentences",ns) ;
- }
-
- int check_end(ch) /* check for end-of sentence char. */
- int ch ;
- {
- if( (ch == '.')
- || (ch == '?')
- || (ch == '!') )
- ns = ns + 1 ;
- }
-
-